#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

typedef struct list
{
    int num;
    list* next;
}list;

int main()
{
    int m = 0;
    int n = 0;
    char c = 0;
    list* l = new list;
    list* p = l;

    while ('}' != c)
    {
        p->next = new list;
        p = p->next;
        scanf("%d", &p->num);
        c = getchar();
    }
    p->next = NULL;
    scanf("%d,%d", &m, &n);

    if(l->next->next)
    {
        int i = 0;
        list* before = l;
        list* rear = NULL;
        list* temp1 = NULL;
        list* temp2 = NULL;
        for (i = 0; i < m - 1; i++)
        {
            before = before->next;
        }
        temp1 = before;
        before = before->next;
        temp2 = before;
        rear = before->next;
        p = rear->next;

        for (i = 0;;)
        {
            rear->next = before;
            if (++i >= m - n)
            {
                break;
            }
            before = rear;
            rear = p;
            p = p->next;
        }

        temp1->next = rear;
        temp2->next = p;
    }

    putchar('{');
    for (p = l->next; ; )
    {
        printf("%d", p->num);
        p = p->next;
        if (!p)
        {
            break;
        }
        putchar(',');
    }
    putchar('}');

    return 0;
}